
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>微信小程序 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-sidebar-style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="../java面试/面试题.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">基础篇</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../java基础/IO流基础.html">
            
                <a href="../java基础/IO流基础.html">
            
                    
                    IO流基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../java基础/集合.html">
            
                <a href="../java基础/集合.html">
            
                    
                    集合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../java基础/异常处理.html">
            
                <a href="../java基础/异常处理.html">
            
                    
                    异常处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../java基础/线程.html">
            
                <a href="../java基础/线程.html">
            
                    
                    线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="../java基础/网络编程.html">
            
                <a href="../java基础/网络编程.html">
            
                    
                    网络编程
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">进阶篇</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../java进阶/MySQL.html">
            
                <a href="../java进阶/MySQL.html">
            
                    
                    MySQL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../java进阶/Oracle.html">
            
                <a href="../java进阶/Oracle.html">
            
                    
                    Oracle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../java进阶/Redis.html">
            
                <a href="../java进阶/Redis.html">
            
                    
                    Redis
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../java进阶/Netty.html">
            
                <a href="../java进阶/Netty.html">
            
                    
                    Netty
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../java进阶/Spring.html">
            
                <a href="../java进阶/Spring.html">
            
                    
                    Spring
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../java进阶/SpringMVC.html">
            
                <a href="../java进阶/SpringMVC.html">
            
                    
                    SpringMVC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../java进阶/单元测试.html">
            
                <a href="../java进阶/单元测试.html">
            
                    
                    SpringBoot单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="../java进阶/设计模式.html">
            
                <a href="../java进阶/设计模式.html">
            
                    
                    二十三个设计模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.8.1" data-path="../java进阶/工厂模式.html">
            
                <a href="../java进阶/工厂模式.html">
            
                    
                    工厂模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.2" data-path="../java进阶/单例模式.html">
            
                <a href="../java进阶/单例模式.html">
            
                    
                    单例模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.3" data-path="../java进阶/建造者模式.html">
            
                <a href="../java进阶/建造者模式.html">
            
                    
                    建造者模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.4" data-path="../java进阶/原型模式.html">
            
                <a href="../java进阶/原型模式.html">
            
                    
                    原型模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.5" data-path="../java进阶/适配器模式.html">
            
                <a href="../java进阶/适配器模式.html">
            
                    
                    适配器模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.6" data-path="../java进阶/责任链模式.html">
            
                <a href="../java进阶/责任链模式.html">
            
                    
                    责任链模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.7" data-path="../java进阶/桥接模式.html">
            
                <a href="../java进阶/桥接模式.html">
            
                    
                    桥接模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">高级篇</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../springcloud/1.cloud架构选型.html">
            
                <a href="../springcloud/1.cloud架构选型.html">
            
                    
                    Spring Cloud
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1.1" data-path="../springcloud/2.Provider-支付模块.html">
            
                <a href="../springcloud/2.Provider-支付模块.html">
            
                    
                    Provider-支付模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.2" data-path="../springcloud/3.Consumer-订单模块.html">
            
                <a href="../springcloud/3.Consumer-订单模块.html">
            
                    
                    Consumer-订单模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.3" data-path="../springcloud/4.重构-Common模块.html">
            
                <a href="../springcloud/4.重构-Common模块.html">
            
                    
                    重构-Common模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.4" data-path="../springcloud/5.注册中心-Enreka.html">
            
                <a href="../springcloud/5.注册中心-Enreka.html">
            
                    
                    注册中心-Enreka
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.5" data-path="../springcloud/6.负载均衡-@LoadBalance.html">
            
                <a href="../springcloud/6.负载均衡-@LoadBalance.html">
            
                    
                    负载均衡-@LoadBalance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.6" data-path="../springcloud/7.更换注册中心-Zookeeper.html">
            
                <a href="../springcloud/7.更换注册中心-Zookeeper.html">
            
                    
                    更换注册中心-Zookeeper
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.7" data-path="../springcloud/8.更换注册中心-Consul.html">
            
                <a href="../springcloud/8.更换注册中心-Consul.html">
            
                    
                    更换注册中心-Consul
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.8" data-path="../springcloud/9.负载均衡-Ribbon.html">
            
                <a href="../springcloud/9.负载均衡-Ribbon.html">
            
                    
                    负载均衡-Ribbon
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.9" data-path="../springcloud/10.服务调用-OpenFeign.html">
            
                <a href="../springcloud/10.服务调用-OpenFeign.html">
            
                    
                    服务调用-OpenFeign
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.10" data-path="../springcloud/11.熔断器-Hystrix.html">
            
                <a href="../springcloud/11.熔断器-Hystrix.html">
            
                    
                    熔断器-Hystrix
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.11" data-path="../springcloud/12.网关-Gateway.html">
            
                <a href="../springcloud/12.网关-Gateway.html">
            
                    
                    网关-Gateway
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.12" data-path="../springcloud/13.配置中心-Config.html">
            
                <a href="../springcloud/13.配置中心-Config.html">
            
                    
                    配置中心-Config
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.13" data-path="../springcloud/14.消息总线-bus.html">
            
                <a href="../springcloud/14.消息总线-bus.html">
            
                    
                    消息总线-Bus
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.14" data-path="../springcloud/15.消息驱动-stream.html">
            
                <a href="../springcloud/15.消息驱动-stream.html">
            
                    
                    消息驱动-Stream
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.15" data-path="../springcloud/16.链路监控-Sleuth.html">
            
                <a href="../springcloud/16.链路监控-Sleuth.html">
            
                    
                    链路监控-Sleuth
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.16" data-path="../springcloud/17.注册中心&配置中心-nacos.html">
            
                <a href="../springcloud/17.注册中心&配置中心-nacos.html">
            
                    
                    注册中心&配置中心-nacos
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.17" data-path="../springcloud/18.限流-sentinel.html">
            
                <a href="../springcloud/18.限流-sentinel.html">
            
                    
                    限流-sentinel
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../java高级/JUC.html">
            
                <a href="../java高级/JUC.html">
            
                    
                    神秘的JUC包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../java高级/Docker.html">
            
                <a href="../java高级/Docker.html">
            
                    
                    Docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../java高级/布隆过滤器.html">
            
                <a href="../java高级/布隆过滤器.html">
            
                    
                    布隆过滤器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../java高级/Redission.html">
            
                <a href="../java高级/Redission.html">
            
                    
                    Redission
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="../java高级/MQ.html">
            
                <a href="../java高级/MQ.html">
            
                    
                    消息队列
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="../java高级/JVM.html">
            
                <a href="../java高级/JVM.html">
            
                    
                    JVM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="../java书籍/《Effective Java》读书笔记.html">
            
                <a href="../java书籍/《Effective Java》读书笔记.html">
            
                    
                    《Effective Java》读书笔记 
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.8.1" data-path="../java书籍/创建和销毁对象.html">
            
                <a href="../java书籍/创建和销毁对象.html">
            
                    
                    创建和销毁对象
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">番外篇</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../java面试/面试题.html">
            
                <a href="../java面试/面试题.html">
            
                    
                    面试题
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="5.2" data-path="小程序.html">
            
                <a href="小程序.html">
            
                    
                    微信小程序
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >微信小程序</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="20&#x5FAE;&#x4FE1;&#x5C0F;&#x7A0B;&#x5E8F;"><a name="20&#x5FAE;&#x4FE1;&#x5C0F;&#x7A0B;&#x5E8F;" class="plugin-anchor" href="#20&#x5FAE;&#x4FE1;&#x5C0F;&#x7A0B;&#x5E8F;"><i class="fa fa-link" aria-hidden="true"></i></a>20.&#x5FAE;&#x4FE1;&#x5C0F;&#x7A0B;&#x5E8F;</h1>
<h4 id="&#x4E00;&#x3001;&#x7A0B;&#x5E8F;&#x6784;&#x9020;&#x5668;app"><a name="&#x4E00;&#x3001;&#x7A0B;&#x5E8F;&#x6784;&#x9020;&#x5668;app" class="plugin-anchor" href="#&#x4E00;&#x3001;&#x7A0B;&#x5E8F;&#x6784;&#x9020;&#x5668;app"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E00;&#x3001;&#x7A0B;&#x5E8F;&#x6784;&#x9020;&#x5668;App()</h4>
<p>&#x5BBF;&#x4E3B;&#x73AF;&#x5883;&#x63D0;&#x4F9B;&#x4E86; App() &#x6784;&#x9020;&#x5668;&#x7528;&#x6765;&#x6CE8;&#x518C;&#x4E00;&#x4E2A;&#x7A0B;&#x5E8F;App&#xFF0C;&#x9700;&#x8981;&#x7559;&#x610F;&#x7684;&#x662F;App() &#x6784;&#x9020;&#x5668;&#x5FC5;&#x987B;&#x5199;&#x5728;&#x9879;&#x76EE;&#x6839;&#x76EE;&#x5F55;&#x7684;<code>app.js</code>&#x91CC;&#xFF0C;App&#x5B9E;&#x4F8B;&#x662F;&#x5355;&#x4F8B;&#x5BF9;&#x8C61;&#xFF0C;&#x5728;&#x5176;&#x4ED6;JS&#x811A;&#x672C;&#x4E2D;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5BBF;&#x4E3B;&#x73AF;&#x5883;&#x63D0;&#x4F9B;&#x7684; getApp() &#x6765;&#x83B7;&#x53D6;&#x7A0B;&#x5E8F;&#x5B9E;&#x4F8B;&#x3002;</p>
<p>App&#x6784;&#x9020;&#x5668;&#x63A5;&#x53D7;&#x4E00;&#x4E2A;Object&#x53C2;&#x6570;&#xFF0C;&#x5176;&#x4E2D;onLaunch / onShow / onHide &#x4E09;&#x4E2A;&#x56DE;&#x8C03;&#x662F;App&#x5B9E;&#x4F8B;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x51FD;&#x6570;&#x3002;</p>
<pre><code class="lang-js">App({
  onLaunch() {
    <span class="hljs-comment">// &#x5C55;&#x793A;&#x672C;&#x5730;&#x5B58;&#x50A8;&#x80FD;&#x529B;</span>
    <span class="hljs-keyword">const</span> logs = wx.getStorageSync(<span class="hljs-string">&apos;logs&apos;</span>) || []
    logs.unshift(<span class="hljs-built_in">Date</span>.now())
    wx.setStorageSync(<span class="hljs-string">&apos;logs&apos;</span>, logs)

    <span class="hljs-comment">// &#x767B;&#x5F55;</span>
    wx.login({
      success: res =&gt; {
        <span class="hljs-comment">// &#x53D1;&#x9001; res.code &#x5230;&#x540E;&#x53F0;&#x6362;&#x53D6; openId, sessionKey, unionId</span>
      }
    })
  },
  globalData: {
    userInfo: <span class="hljs-literal">null</span>
  }
})
</code></pre>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x5C5E;&#x6027;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x63CF;&#x8FF0;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">onLaunch</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5F53;&#x5C0F;&#x7A0B;&#x5E8F;&#x521D;&#x59CB;&#x5316;&#x5B8C;&#x6210;&#x65F6;&#xFF0C;&#x4F1A;&#x89E6;&#x53D1; onLaunch&#xFF08;&#x5168;&#x5C40;&#x53EA;&#x89E6;&#x53D1;&#x4E00;&#x6B21;&#xFF09;</td>
</tr>
<tr>
<td style="text-align:left">onShow</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5F53;&#x5C0F;&#x7A0B;&#x5E8F;&#x542F;&#x52A8;&#xFF0C;&#x6216;&#x4ECE;&#x540E;&#x53F0;&#x8FDB;&#x5165;&#x524D;&#x53F0;&#x663E;&#x793A;&#xFF0C;&#x4F1A;&#x89E6;&#x53D1; onShow</td>
</tr>
<tr>
<td style="text-align:left">onHide</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5F53;&#x5C0F;&#x7A0B;&#x5E8F;&#x4ECE;&#x524D;&#x53F0;&#x8FDB;&#x5165;&#x540E;&#x53F0;&#xFF0C;&#x4F1A;&#x89E6;&#x53D1; onHide</td>
</tr>
<tr>
<td style="text-align:left">onError</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x5F53;&#x5C0F;&#x7A0B;&#x5E8F;&#x53D1;&#x751F;&#x811A;&#x672C;&#x9519;&#x8BEF;&#xFF0C;&#x6216;&#x8005; API &#x8C03;&#x7528;&#x5931;&#x8D25;&#x65F6;&#xFF0C;&#x4F1A;&#x89E6;&#x53D1; onError &#x5E76;&#x5E26;&#x4E0A;&#x9519;&#x8BEF;&#x4FE1;&#x606F;</td>
</tr>
<tr>
<td style="text-align:left">&#x5176;&#x4ED6;&#x5B57;&#x6BB5;</td>
<td style="text-align:left">&#x4EFB;&#x610F;</td>
<td style="text-align:left">&#x53EF;&#x4EE5;&#x6DFB;&#x52A0;&#x4EFB;&#x610F;&#x7684;&#x51FD;&#x6570;&#x6216;&#x6570;&#x636E;&#x5230; Object &#x53C2;&#x6570;&#x4E2D;&#xFF0C;&#x5728;App&#x5B9E;&#x4F8B;&#x56DE;&#x8C03;&#x7528; this &#x53EF;&#x4EE5;&#x8BBF;&#x95EE;</td>
</tr>
</tbody>
</table>
<h4 id="&#x4E8C;&#x3001;&#x7A0B;&#x5E8F;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x548C;&#x6253;&#x5F00;&#x573A;&#x666F;"><a name="&#x4E8C;&#x3001;&#x7A0B;&#x5E8F;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x548C;&#x6253;&#x5F00;&#x573A;&#x666F;" class="plugin-anchor" href="#&#x4E8C;&#x3001;&#x7A0B;&#x5E8F;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x548C;&#x6253;&#x5F00;&#x573A;&#x666F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E8C;&#x3001;&#x7A0B;&#x5E8F;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x548C;&#x6253;&#x5F00;&#x573A;&#x666F;</h4>
<p>&#x521D;&#x6B21;&#x8FDB;&#x5165;&#x5C0F;&#x7A0B;&#x5E8F;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5FAE;&#x4FE1;&#x5BA2;&#x6237;&#x7AEF;&#x521D;&#x59CB;&#x5316;&#x597D;&#x5BBF;&#x4E3B;&#x73AF;&#x5883;&#xFF0C;&#x540C;&#x65F6;&#x4ECE;&#x7F51;&#x7EDC;&#x4E0B;&#x8F7D;&#x6216;&#x8005;&#x4ECE;&#x672C;&#x5730;&#x7F13;&#x5B58;&#x4E2D;&#x62FF;&#x5230;&#x5C0F;&#x7A0B;&#x5E8F;&#x7684;&#x4EE3;&#x7801;&#x5305;&#xFF0C;&#x628A;&#x5B83;&#x6CE8;&#x5165;&#x5230;&#x5BBF;&#x4E3B;&#x73AF;&#x5883;&#xFF0C;&#x521D;&#x59CB;&#x5316;&#x5B8C;&#x6BD5;&#x540E;&#xFF0C;&#x5FAE;&#x4FE1;&#x5BA2;&#x6237;&#x7AEF;&#x5C31;&#x4F1A;&#x7ED9;App&#x5B9E;&#x4F8B;&#x6D3E;&#x53D1;<code>onLaunch</code>&#x4E8B;&#x4EF6;&#xFF0C;<u>App&#x6784;&#x9020;&#x5668;&#x53C2;&#x6570;&#x6240;&#x5B9A;&#x4E49;&#x7684;onLaunch&#x65B9;&#x6CD5;&#x4F1A;&#x88AB;&#x8C03;&#x7528;</u>&#x3002;</p>
<p>&#x8FDB;&#x5165;&#x5C0F;&#x7A0B;&#x5E8F;&#x4E4B;&#x540E;&#xFF0C;&#x7528;&#x6237;&#x53EF;&#x4EE5;&#x70B9;&#x51FB;&#x53F3;&#x4E0A;&#x89D2;&#x7684;&#x5173;&#x95ED;&#xFF0C;&#x6216;&#x8005;&#x6309;&#x624B;&#x673A;&#x8BBE;&#x5907;&#x7684;Home&#x952E;&#x79BB;&#x5F00;&#x5C0F;&#x7A0B;&#x5E8F;&#xFF0C;&#x6B64;&#x65F6;&#x5C0F;&#x7A0B;&#x5E8F;&#x5E76;&#x6CA1;&#x6709;&#x88AB;&#x76F4;&#x63A5;&#x9500;&#x6BC1;&#xFF0C;&#x6211;&#x4EEC;&#x628A;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x79F0;&#x4E3A;&#x201C;&#x5C0F;&#x7A0B;&#x5E8F;&#x8FDB;&#x5165;&#x540E;&#x53F0;&#x72B6;&#x6001;&#x201D;&#xFF0C;<u>App&#x6784;&#x9020;&#x5668;&#x53C2;&#x6570;&#x6240;&#x5B9A;&#x4E49;&#x7684;<code>onHide</code>&#x65B9;&#x6CD5;&#x4F1A;&#x88AB;&#x8C03;&#x7528;</u>&#x3002;</p>
<p>&#x5F53;&#x518D;&#x6B21;&#x56DE;&#x5230;&#x5FAE;&#x4FE1;&#x6216;&#x8005;&#x518D;&#x6B21;&#x6253;&#x5F00;&#x5C0F;&#x7A0B;&#x5E8F;&#x65F6;&#xFF0C;&#x5FAE;&#x4FE1;&#x5BA2;&#x6237;&#x7AEF;&#x4F1A;&#x628A;&#x201C;&#x540E;&#x53F0;&#x201D;&#x7684;&#x5C0F;&#x7A0B;&#x5E8F;&#x5524;&#x9192;&#xFF0C;&#x6211;&#x4EEC;&#x628A;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x79F0;&#x4E3A;&#x201C;&#x5C0F;&#x7A0B;&#x5E8F;&#x8FDB;&#x5165;&#x524D;&#x53F0;&#x72B6;&#x6001;&#x201D;&#xFF0C;<u>App&#x6784;&#x9020;&#x5668;&#x53C2;&#x6570;&#x6240;&#x5B9A;&#x4E49;&#x7684;<code>onShow</code>&#x65B9;&#x6CD5;&#x4F1A;&#x88AB;&#x8C03;&#x7528;</u>&#x3002;</p>
<p>&#x4ECE;&#x7FA4;&#x804A;&#x4F1A;&#x8BDD;&#x91CC;&#x6253;&#x5F00;&#xFF0C;&#x4ECE;&#x5C0F;&#x7A0B;&#x5E8F;&#x5217;&#x8868;&#x4E2D;&#x6253;&#x5F00;&#xFF0C;&#x901A;&#x8FC7;&#x5FAE;&#x4FE1;&#x626B;&#x4E00;&#x626B;&#x4E8C;&#x7EF4;&#x7801;&#x6253;&#x5F00;&#xFF0C;&#x4ECE;&#x53E6;&#x5916;&#x4E00;&#x4E2A;&#x5C0F;&#x7A0B;&#x5E8F;&#x6253;&#x5F00;&#x5F53;&#x524D;&#x5C0F;&#x7A0B;&#x5E8F;&#x7B49;&#xFF0C;&#x9488;&#x5BF9;&#x4E0D;&#x540C;&#x9014;&#x5F84;&#x7684;&#x6253;&#x5F00;&#x65B9;&#x5F0F;&#xFF0C;&#x5C0F;&#x7A0B;&#x5E8F;&#x6709;&#x65F6;&#x9700;&#x8981;&#x505A;&#x4E0D;&#x540C;&#x7684;&#x4E1A;&#x52A1;&#x5904;&#x7406;&#xFF0C;&#x6240;&#x4EE5;&#x5FAE;&#x4FE1;&#x5BA2;&#x6237;&#x7AEF;&#x4F1A;&#x628A;&#x6253;&#x5F00;&#x65B9;&#x5F0F;&#x5E26;&#x7ED9;onLaunch&#x548C;onShow&#x7684;&#x8C03;&#x7528;&#x53C2;&#x6570;options&#x3002;&#x5177;&#x4F53;&#x53C2;&#x6570;&#x67E5;&#x770B;&#x5B98;&#x65B9;&#x6587;&#x6863;&#x3002;</p>
<p>App&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x662F;&#x7531;&#x5FAE;&#x4FE1;&#x5BA2;&#x6237;&#x7AEF;&#x6839;&#x636E;&#x7528;&#x6237;&#x64CD;&#x4F5C;&#x4E3B;&#x52A8;&#x89E6;&#x53D1;&#x7684;&#x3002;&#x4E3A;&#x4E86;&#x907F;&#x514D;&#x7A0B;&#x5E8F;&#x4E0A;&#x7684;&#x6DF7;&#x4E71;&#xFF0C;&#x6211;&#x4EEC;&#x4E0D;&#x5E94;&#x8BE5;&#x4ECE;&#x5176;&#x4ED6;&#x4EE3;&#x7801;&#x91CC;&#x4E3B;&#x52A8;&#x8C03;&#x7528;App&#x5B9E;&#x4F8B;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x51FD;&#x6570;&#x3002;</p>
<h4 id="&#x4E09;&#x3001;&#x5C0F;&#x7A0B;&#x5E8F;&#x5168;&#x5C40;&#x6570;&#x636E;"><a name="&#x4E09;&#x3001;&#x5C0F;&#x7A0B;&#x5E8F;&#x5168;&#x5C40;&#x6570;&#x636E;" class="plugin-anchor" href="#&#x4E09;&#x3001;&#x5C0F;&#x7A0B;&#x5E8F;&#x5168;&#x5C40;&#x6570;&#x636E;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E09;&#x3001;&#x5C0F;&#x7A0B;&#x5E8F;&#x5168;&#x5C40;&#x6570;&#x636E;</h4>
<p>App&#x5B9E;&#x4F8B;&#x662F;&#x5355;&#x4F8B;&#x7684;&#xFF0C;&#x56E0;&#x6B64;&#x4E0D;&#x540C;&#x9875;&#x9762;&#x76F4;&#x63A5;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;App&#x5B9E;&#x4F8B;&#x4E0B;&#x7684;&#x5C5E;&#x6027;&#x6765;&#x5171;&#x4EAB;&#x6570;&#x636E;&#x3002;App&#x6784;&#x9020;&#x5668;&#x53EF;&#x4EE5;&#x4F20;&#x9012;&#x5176;&#x4ED6;&#x53C2;&#x6570;&#x4F5C;&#x4E3A;&#x5168;&#x5C40;&#x5C5E;&#x6027;&#x4EE5;&#x8FBE;&#x5230;&#x5168;&#x5C40;&#x5171;&#x4EAB;&#x6570;&#x636E;&#x7684;&#x76EE;&#x7684;&#x3002;</p>
<pre><code class="lang-js"><span class="hljs-comment">// app.js</span>
App({
  globalData: <span class="hljs-string">&apos;I am global data&apos;</span> <span class="hljs-comment">// &#x5168;&#x5C40;&#x5171;&#x4EAB;&#x6570;&#x636E;</span>
})
<span class="hljs-comment">// &#x5176;&#x4ED6;&#x9875;&#x9762;&#x811A;&#x672C;other.js</span>
<span class="hljs-keyword">var</span> appInstance = getApp()
<span class="hljs-built_in">console</span>.log(appInstance.globalData) <span class="hljs-comment">// &#x8F93;&#x51FA;: I am global data</span>
</code></pre>
<p>&#x4E0E;&#x6B64;&#x540C;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x8981;&#x7279;&#x522B;&#x7559;&#x610F;&#x4E00;&#x70B9;&#xFF0C;<u>&#x6240;&#x6709;&#x9875;&#x9762;&#x7684;&#x811A;&#x672C;&#x903B;&#x8F91;&#x90FD;&#x8DD1;&#x5728;&#x540C;&#x4E00;&#x4E2A;JsCore&#x7EBF;&#x7A0B;&#xFF0C;&#x9875;&#x9762;&#x4F7F;&#x7528;setTimeout&#x6216;&#x8005;setInterval&#x7684;&#x5B9A;&#x65F6;&#x5668;&#xFF0C;&#x7136;&#x540E;&#x8DF3;&#x8F6C;&#x5230;&#x5176;&#x4ED6;&#x9875;&#x9762;&#x65F6;&#xFF0C;&#x8FD9;&#x4E9B;&#x5B9A;&#x65F6;&#x5668;&#x5E76;&#x6CA1;&#x6709;&#x88AB;&#x6E05;&#x9664;&#xFF0C;&#x9700;&#x8981;&#x5F00;&#x53D1;&#x8005;&#x81EA;&#x5DF1;&#x5728;&#x9875;&#x9762;&#x79BB;&#x5F00;&#x7684;&#x65F6;&#x5019;&#x8FDB;&#x884C;&#x6E05;&#x7406;</u>&#x3002;</p>
<h4 id="&#x56DB;&#x3001;&#x9875;&#x9762;"><a name="&#x56DB;&#x3001;&#x9875;&#x9762;" class="plugin-anchor" href="#&#x56DB;&#x3001;&#x9875;&#x9762;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x56DB;&#x3001;&#x9875;&#x9762;</h4>
<p>&#x4E00;&#x4E2A;&#x9875;&#x9762;&#x662F;&#x5206;&#x4E09;&#x90E8;&#x5206;&#x7EC4;&#x6210;&#xFF1A;<strong>&#x754C;&#x9762;&#x3001;&#x914D;&#x7F6E;&#x548C;&#x903B;&#x8F91;</strong>&#x3002;&#x754C;&#x9762;&#x7531;WXML&#x6587;&#x4EF6;&#x548C;WXSS&#x6587;&#x4EF6;&#x6765;&#x8D1F;&#x8D23;&#x63CF;&#x8FF0;&#xFF0C;&#x914D;&#x7F6E;&#x7531;JSON&#x6587;&#x4EF6;&#x8FDB;&#x884C;&#x63CF;&#x8FF0;&#xFF0C;&#x9875;&#x9762;&#x903B;&#x8F91;&#x5219;&#x662F;&#x7531;JS&#x811A;&#x672C;&#x6587;&#x4EF6;&#x8D1F;&#x8D23;&#x3002;&#x4E00;&#x4E2A;&#x9875;&#x9762;&#x7684;&#x6587;&#x4EF6;&#x9700;&#x8981;&#x653E;&#x7F6E;&#x5728;&#x540C;&#x4E00;&#x4E2A;&#x76EE;&#x5F55;&#x4E0B;&#xFF0C;<u>&#x5176;&#x4E2D;WXML&#x6587;&#x4EF6;&#x548C;JS&#x6587;&#x4EF6;&#x662F;&#x5FC5;&#x987B;&#x5B58;&#x5728;&#x7684;&#xFF0C;JSON&#x548C;WXSS&#x6587;&#x4EF6;&#x662F;&#x53EF;&#x9009;&#x7684;</u>&#x3002;</p>
<p>&#x9875;&#x9762;&#x8DEF;&#x5F84;&#x9700;&#x8981;&#x5728;&#x5C0F;&#x7A0B;&#x5E8F;&#x4EE3;&#x7801;&#x6839;&#x76EE;&#x5F55;app.json&#x4E2D;&#x7684;pages&#x5B57;&#x6BB5;&#x58F0;&#x660E;&#xFF0C;&#x5426;&#x5219;&#x8FD9;&#x4E2A;&#x9875;&#x9762;&#x4E0D;&#x4F1A;&#x88AB;&#x6CE8;&#x518C;&#x5230;&#x5BBF;&#x4E3B;&#x73AF;&#x5883;&#x4E2D;&#x3002;&#x4F8B;&#x5982;&#x4E24;&#x4E2A;&#x9875;&#x9762;&#x7684;&#x6587;&#x4EF6;&#x7684;&#x76F8;&#x5BF9;&#x8DEF;&#x5F84;&#x5206;&#x522B;&#x4E3A; <em>pages/index/page.</em> <em>&#x548C; pages/other/other</em></p>
<pre><code class="lang-json"><span class="hljs-comment">//app.json</span>
{
  <span class="hljs-string">&quot;pages&quot;</span>:[
    <span class="hljs-string">&quot;pages/index/page&quot;</span>, <span class="hljs-comment">// &#x7B2C;&#x4E00;&#x9879;&#x9ED8;&#x8BA4;&#x4E3A;&#x9996;&#x9875;</span>
    <span class="hljs-string">&quot;pages/other/other&quot;</span>
  ]
}
</code></pre>
<h4 id="&#x4E94;&#x3001;&#x9875;&#x9762;&#x6784;&#x9020;&#x5668;page"><a name="&#x4E94;&#x3001;&#x9875;&#x9762;&#x6784;&#x9020;&#x5668;page" class="plugin-anchor" href="#&#x4E94;&#x3001;&#x9875;&#x9762;&#x6784;&#x9020;&#x5668;page"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E94;&#x3001;&#x9875;&#x9762;&#x6784;&#x9020;&#x5668;Page()</h4>
<p>&#x5BBF;&#x4E3B;&#x73AF;&#x5883;&#x63D0;&#x4F9B;&#x4E86; Page() &#x6784;&#x9020;&#x5668;&#x7528;&#x6765;&#x6CE8;&#x518C;&#x4E00;&#x4E2A;&#x5C0F;&#x7A0B;&#x5E8F;&#x9875;&#x9762;&#xFF0C;Page()&#x5728;&#x9875;&#x9762;&#x811A;&#x672C;page.js&#x4E2D;&#x8C03;&#x7528;&#x3002;Page&#x6784;&#x9020;&#x5668;&#x63A5;&#x53D7;&#x4E00;&#x4E2A;Object&#x53C2;&#x6570;&#xFF1B;&#x5176;&#x4E2D;data&#x5C5E;&#x6027;&#x662F;&#x5F53;&#x524D;&#x9875;&#x9762;WXML&#x6A21;&#x677F;&#x4E2D;&#x53EF;&#x4EE5;&#x7528;&#x6765;&#x505A;&#x6570;&#x636E;&#x7ED1;&#x5B9A;&#x7684;&#x521D;&#x59CB;&#x6570;&#x636E;&#xFF1B;onLoad / onReady / onShow / onHide /onUnload 5&#x4E2A;&#x56DE;&#x8C03;&#x662F;Page&#x5B9E;&#x4F8B;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x51FD;&#x6570;&#xFF1B;onPullDownRefresh / onReachBottom / onShareAppMessage / onPageScroll 4&#x4E2A;&#x56DE;&#x8C03;&#x662F;&#x9875;&#x9762;&#x7684;&#x7528;&#x6237;&#x884C;&#x4E3A;&#x3002;</p>
<pre><code class="lang-js">Page({
  data: { text: <span class="hljs-string">&quot;This is page data.&quot;</span> },
  onLoad: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">options</span>) </span>{ },
  onReady: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ },
  onShow: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ },
  onHide: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ },
  onUnload: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ },
  onPullDownRefresh: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ },
  onReachBottom: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ },
  onShareAppMessage: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{ },
  onPageScroll: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ }
})
</code></pre>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x5C5E;&#x6027;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x63CF;&#x8FF0;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">data</td>
<td style="text-align:left">Object</td>
<td style="text-align:left">&#x9875;&#x9762;&#x7684;&#x521D;&#x59CB;&#x6570;&#x636E;</td>
</tr>
<tr>
<td style="text-align:left">onLoad</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x751F;&#x547D;&#x5468;&#x671F;&#x51FD;&#x6570;--&#x76D1;&#x542C;&#x9875;&#x9762;&#x52A0;&#x8F7D;&#xFF0C;&#x89E6;&#x53D1;&#x65F6;&#x673A;&#x65E9;&#x4E8E;onShow&#x548C;onReady</td>
</tr>
<tr>
<td style="text-align:left">onReady</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x751F;&#x547D;&#x5468;&#x671F;&#x51FD;&#x6570;--&#x76D1;&#x542C;&#x9875;&#x9762;&#x521D;&#x6B21;&#x6E32;&#x67D3;&#x5B8C;&#x6210;</td>
</tr>
<tr>
<td style="text-align:left">onShow</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x751F;&#x547D;&#x5468;&#x671F;&#x51FD;&#x6570;--&#x76D1;&#x542C;&#x9875;&#x9762;&#x663E;&#x793A;&#xFF0C;&#x89E6;&#x53D1;&#x4E8B;&#x4EF6;&#x65E9;&#x4E8E;onReady</td>
</tr>
<tr>
<td style="text-align:left">onHide</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x751F;&#x547D;&#x5468;&#x671F;&#x51FD;&#x6570;--&#x76D1;&#x542C;&#x9875;&#x9762;&#x9690;&#x85CF;</td>
</tr>
<tr>
<td style="text-align:left">onUnload</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x751F;&#x547D;&#x5468;&#x671F;&#x51FD;&#x6570;--&#x76D1;&#x542C;&#x9875;&#x9762;&#x5378;&#x8F7D;</td>
</tr>
<tr>
<td style="text-align:left">onPullDownRefresh</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x9875;&#x9762;&#x76F8;&#x5173;&#x4E8B;&#x4EF6;&#x5904;&#x7406;&#x51FD;&#x6570;--&#x76D1;&#x542C;&#x7528;&#x6237;&#x4E0B;&#x62C9;&#x52A8;&#x4F5C;</td>
</tr>
<tr>
<td style="text-align:left">onReachBottom</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x9875;&#x9762;&#x4E0A;&#x62C9;&#x89E6;&#x5E95;&#x4E8B;&#x4EF6;&#x7684;&#x5904;&#x7406;&#x51FD;&#x6570;</td>
</tr>
<tr>
<td style="text-align:left">onShareAppMessage</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x7528;&#x6237;&#x70B9;&#x51FB;&#x53F3;&#x4E0A;&#x89D2;&#x8F6C;&#x53D1;</td>
</tr>
<tr>
<td style="text-align:left">onPageScroll</td>
<td style="text-align:left">Function</td>
<td style="text-align:left">&#x9875;&#x9762;&#x6EDA;&#x52A8;&#x89E6;&#x53D1;&#x4E8B;&#x4EF6;&#x7684;&#x5904;&#x7406;&#x51FD;&#x6570;</td>
</tr>
<tr>
<td style="text-align:left">&#x5176;&#x4ED6;</td>
<td style="text-align:left">Any</td>
<td style="text-align:left">&#x53EF;&#x4EE5;&#x6DFB;&#x52A0;&#x4EFB;&#x610F;&#x7684;&#x51FD;&#x6570;&#x6216;&#x6570;&#x636E;&#xFF0C;&#x5728;Page&#x5B9E;&#x4F8B;&#x7684;&#x5176;&#x4ED6;&#x51FD;&#x6570;&#x4E2D;&#x7528; this &#x53EF;&#x4EE5;&#x8BBF;&#x95EE;</td>
</tr>
</tbody>
</table>
<h4 id="&#x516D;&#x3001;&#x9875;&#x9762;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x548C;&#x6253;&#x5F00;&#x53C2;&#x6570;"><a name="&#x516D;&#x3001;&#x9875;&#x9762;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x548C;&#x6253;&#x5F00;&#x53C2;&#x6570;" class="plugin-anchor" href="#&#x516D;&#x3001;&#x9875;&#x9762;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x548C;&#x6253;&#x5F00;&#x53C2;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x516D;&#x3001;&#x9875;&#x9762;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x548C;&#x6253;&#x5F00;&#x53C2;&#x6570;</h4>
<p>&#x9875;&#x9762;&#x521D;&#x6B21;&#x52A0;&#x8F7D;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5FAE;&#x4FE1;&#x5BA2;&#x6237;&#x7AEF;&#x5C31;&#x4F1A;&#x7ED9;Page&#x5B9E;&#x4F8B;&#x6D3E;&#x53D1;onLoad&#x4E8B;&#x4EF6;&#xFF0C;Page&#x6784;&#x9020;&#x5668;&#x53C2;&#x6570;&#x6240;&#x5B9A;&#x4E49;&#x7684;onLoad&#x65B9;&#x6CD5;&#x4F1A;&#x88AB;&#x8C03;&#x7528;&#xFF0C;onLoad&#x5728;&#x9875;&#x9762;&#x6CA1;&#x88AB;&#x9500;&#x6BC1;&#x4E4B;&#x524D;&#x53EA;&#x4F1A;&#x89E6;&#x53D1;1&#x6B21;&#xFF0C;&#x5728;onLoad&#x7684;&#x56DE;&#x8C03;&#x4E2D;&#xFF0C;&#x53EF;&#x4EE5;&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x9875;&#x9762;&#x6240;&#x8C03;&#x7528;&#x7684;&#x6253;&#x5F00;&#x53C2;&#x6570;option&#xFF0C;&#x5173;&#x4E8E;&#x6253;&#x5F00;&#x53C2;&#x6570;&#x6211;&#x4EEC;&#x653E;&#x5728;&#x8FD9;&#x4E00;&#x8282;&#x7684;&#x6700;&#x540E;&#x518D;&#x5C55;&#x5F00;&#x9610;&#x8FF0;&#x3002;
&#x9875;&#x9762;&#x663E;&#x793A;&#x4E4B;&#x540E;&#xFF0C;Page&#x6784;&#x9020;&#x5668;&#x53C2;&#x6570;&#x6240;&#x5B9A;&#x4E49;&#x7684;onShow&#x65B9;&#x6CD5;&#x4F1A;&#x88AB;&#x8C03;&#x7528;&#xFF0C;&#x4E00;&#x822C;&#x4ECE;&#x522B;&#x7684;&#x9875;&#x9762;&#x8FD4;&#x56DE;&#x5230;&#x5F53;&#x524D;&#x9875;&#x9762;&#x65F6;&#xFF0C;&#x5F53;&#x524D;&#x9875;&#x7684;onShow&#x65B9;&#x6CD5;&#x90FD;&#x4F1A;&#x88AB;&#x8C03;&#x7528;&#x3002;
&#x5728;&#x9875;&#x9762;&#x521D;&#x6B21;&#x6E32;&#x67D3;&#x5B8C;&#x6210;&#x65F6;&#xFF0C;Page&#x6784;&#x9020;&#x5668;&#x53C2;&#x6570;&#x6240;&#x5B9A;&#x4E49;&#x7684;onReady&#x65B9;&#x6CD5;&#x4F1A;&#x88AB;&#x8C03;&#x7528;&#xFF0C;onReady&#x5728;&#x9875;&#x9762;&#x6CA1;&#x88AB;&#x9500;&#x6BC1;&#x524D;&#x53EA;&#x4F1A;&#x89E6;&#x53D1;1&#x6B21;&#xFF0C;onReady&#x89E6;&#x53D1;&#x65F6;&#xFF0C;&#x8868;&#x793A;&#x9875;&#x9762;&#x5DF2;&#x7ECF;&#x51C6;&#x5907;&#x59A5;&#x5F53;&#xFF0C;&#x5728;&#x903B;&#x8F91;&#x5C42;&#x5C31;&#x53EF;&#x4EE5;&#x548C;&#x89C6;&#x56FE;&#x5C42;&#x8FDB;&#x884C;&#x4EA4;&#x4E92;&#x4E86;&#x3002;
&#x4EE5;&#x4E0A;&#x4E09;&#x4E2A;&#x4E8B;&#x4EF6;&#x89E6;&#x53D1;&#x7684;&#x65F6;&#x673A;&#x662F;onLoad&#x65E9;&#x4E8E; onShow&#xFF0C;onShow&#x65E9;&#x4E8E;onReady&#x3002;
&#x9875;&#x9762;&#x4E0D;&#x53EF;&#x89C1;&#x65F6;&#xFF0C;Page&#x6784;&#x9020;&#x5668;&#x53C2;&#x6570;&#x6240;&#x5B9A;&#x4E49;&#x7684;onHide&#x65B9;&#x6CD5;&#x4F1A;&#x88AB;&#x8C03;&#x7528;&#xFF0C;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4F1A;&#x5728;&#x4F7F;&#x7528;wx.navigateTo&#x5207;&#x6362;&#x5230;&#x5176;&#x4ED6;&#x9875;&#x9762;&#x3001;&#x5E95;&#x90E8;tab&#x5207;&#x6362;&#x65F6;&#x89E6;&#x53D1;&#x3002;
&#x5F53;&#x524D;&#x9875;&#x9762;&#x4F7F;&#x7528;wx.redirectTo&#x6216;wx.navigateBack&#x8FD4;&#x56DE;&#x5230;&#x5176;&#x4ED6;&#x9875;&#x65F6;&#xFF0C;&#x5F53;&#x524D;&#x9875;&#x9762;&#x4F1A;&#x88AB;&#x5FAE;&#x4FE1;&#x5BA2;&#x6237;&#x7AEF;&#x9500;&#x6BC1;&#x56DE;&#x6536;&#xFF0C;&#x6B64;&#x65F6;Page&#x6784;&#x9020;&#x5668;&#x53C2;&#x6570;&#x6240;&#x5B9A;&#x4E49;&#x7684;onUnload&#x65B9;&#x6CD5;&#x4F1A;&#x88AB;&#x8C03;&#x7528;&#x3002;
&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;Page&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x662F;&#x7531;&#x5FAE;&#x4FE1;&#x5BA2;&#x6237;&#x7AEF;&#x6839;&#x636E;&#x7528;&#x6237;&#x64CD;&#x4F5C;&#x4E3B;&#x52A8;&#x89E6;&#x53D1;&#x7684;&#x3002;&#x4E3A;&#x4E86;&#x907F;&#x514D;&#x7A0B;&#x5E8F;&#x4E0A;&#x7684;&#x6DF7;&#x4E71;&#xFF0C;&#x6211;&#x4EEC;&#x4E0D;&#x5E94;&#x8BE5;&#x5728;&#x5176;&#x4ED6;&#x4EE3;&#x7801;&#x4E2D;&#x4E3B;&#x52A8;&#x8C03;&#x7528;Page&#x5B9E;&#x4F8B;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x51FD;&#x6570;&#x3002;
&#x6700;&#x540E;&#x6211;&#x4EEC;&#x8BF4;&#x4E00;&#x4E0B;&#x9875;&#x9762;&#x7684;&#x6253;&#x5F00;&#x53C2;&#x6570;query&#xFF0C;&#x8BA9;&#x6211;&#x4EEC;&#x6765;&#x8BBE;&#x60F3;&#x8FD9;&#x6837;&#x4E00;&#x4E2A;&#x573A;&#x666F;&#xFF0C;&#x6211;&#x4EEC;&#x5B9E;&#x73B0;&#x4E00;&#x4E2A;&#x8D2D;&#x7269;&#x5546;&#x57CE;&#x7684;&#x5C0F;&#x7A0B;&#x5E8F;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5B8C;&#x6210;&#x4E00;&#x4E2A;&#x5546;&#x54C1;&#x5217;&#x8868;&#x9875;&#x548C;&#x5546;&#x54C1;&#x8BE6;&#x60C5;&#x9875;&#xFF0C;&#x70B9;&#x51FB;&#x5546;&#x54C1;&#x5217;&#x8868;&#x9875;&#x7684;&#x5546;&#x54C1;&#x5C31;&#x53EF;&#x4EE5;&#x8DF3;&#x8F6C;&#x5230;&#x8BE5;&#x5546;&#x54C1;&#x7684;&#x8BE6;&#x60C5;&#x9875;&#xFF0C;&#x5F53;&#x7136;&#x6211;&#x4EEC;&#x4E0D;&#x53EF;&#x80FD;&#x4E3A;&#x6BCF;&#x4E2A;&#x5546;&#x54C1;&#x5355;&#x72EC;&#x53BB;&#x5B9E;&#x73B0;&#x5B83;&#x7684;&#x8BE6;&#x60C5;&#x9875;&#x3002;&#x6211;&#x4EEC;&#x53EA;&#x9700;&#x8981;&#x5B9E;&#x73B0;&#x4E00;&#x4E2A;&#x5546;&#x54C1;&#x8BE6;&#x60C5;&#x9875;&#x7684;pages/detail/detail.<em>(&#x4EE3;&#x8868;WXML/WXSS/JS/JSON&#x6587;&#x4EF6;)</em>&#x5373;&#x53EF;&#xFF0C;&#x5728;&#x5217;&#x8868;&#x9875;&#x6253;&#x5F00;&#x5546;&#x54C1;&#x8BE6;&#x60C5;&#x9875;&#x65F6;&#x628A;&#x5546;&#x54C1;&#x7684;id&#x4F20;&#x9012;&#x8FC7;&#x6765;&#xFF0C;&#x8BE6;&#x60C5;&#x9875;&#x901A;&#x8FC7;&#x521A;&#x521A;&#x8BF4;&#x7684;onLoad&#x56DE;&#x8C03;&#x7684;&#x53C2;&#x6570;option&#x5C31;&#x53EF;&#x4EE5;&#x62FF;&#x5230;&#x5546;&#x54C1;id&#xFF0C;&#x4ECE;&#x800C;&#x7ED8;&#x5236;&#x51FA;&#x5BF9;&#x5E94;&#x7684;&#x5546;&#x54C1;</p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; mine 2022-2025 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2022-03-22 18:05:33
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../java面试/面试题.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: 面试题">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"微信小程序","level":"5.2","depth":1,"previous":{"title":"面试题","level":"5.1","depth":1,"path":"java面试/面试题.md","ref":"java面试/面试题.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["back-to-top-button","code","splitter","expandable-chapters-small","anchors","theme-comscore","tbfed-pagefooter","sidebar-style","pageview-count","popup"],"pluginsConfig":{"sidebar-style":{"author":"梁兴龙","title":"《Java 笔记本》"},"tbfed-pagefooter":{"copyright":"Copyright &copy mine 2022-2025","modify_label":"文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"splitter":{},"search":{},"popup":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"code":{"copyButtons":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"theme-comscore":{},"back-to-top-button":{},"pageview-count":{},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"番外篇/小程序.md","mtime":"2022-03-22T10:05:33.422Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-08-22T03:22:22.085Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sidebar-style/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

